package com.ywq.app.dao;

import java.util.List;
import java.util.Map;

import com.ywq.app.domain.AdminResource;
import com.ywq.app.domain.AdminRole;
import com.ywq.app.domain.AdminUser;
import com.ywq.common.exception.AppBusinessException;



public interface AdminDao {

	void insertResource(AdminResource adminResource)
			throws AppBusinessException;

	void updateResource(AdminResource adminResource)
			throws AppBusinessException;

	void deleteResourceById(String resourceId) throws AppBusinessException;

	void insertRole(AdminRole adminRole) throws AppBusinessException;

	void updateRole(AdminRole adminRole) throws AppBusinessException;

	void deleteRoleById(String roleId) throws AppBusinessException;

	void insertUser(AdminUser adminUser) throws AppBusinessException;

	void updateUser(AdminUser adminUser) throws AppBusinessException;

	void deleteUserById(String userId) throws AppBusinessException;

	AdminUser getUserByUsername(String username) throws AppBusinessException;

	/**
	 * 获取所有角色(权限)列表.
	 * 
	 * @return
	 * @throws AppBusinessException
	 */
	List<AdminRole> getAuthorityList() throws AppBusinessException;

	List<AdminUser> getUserList(Map<String, Object> map)
			throws AppBusinessException;

	/**
	 * 根据用户名获取用户的角色(权限)列表.
	 * 
	 * @param username
	 * @return
	 * @throws AppBusinessException
	 */
	List<AdminRole> getUserAuthorityList(String username)
			throws AppBusinessException;

	/**
	 * 根据角色(权限)查询资源列表
	 * 
	 * @param authorityName
	 * @return
	 * @throws AppBusinessException
	 */
	List<AdminResource> getResourceListByAuthorityName(String authorityName)
			throws AppBusinessException;

	int getAdminUserCount(Map<String, Object> map) throws AppBusinessException;

	/**
	 * 通过userId查询user的role.
	 * 
	 * @param id
	 * @return
	 * @throws AppBusinessException
	 */
	List<AdminRole> getAdminUserRole(String id) throws AppBusinessException;

	/**
	 * 根据用户id删除用户和角色的绑定关系.
	 * 
	 * @param userId
	 * @throws AppBusinessException
	 */
	void deleteUserRoleByUserId(String userId) throws AppBusinessException;

	/**
	 * 根据角色id删除用户和角色的绑定关系.
	 * 
	 * @param roleId
	 * @throws AppBusinessException
	 */
	void deleteUserRoleByRoleId(String roleId) throws AppBusinessException;

	void insertUserRoleId(Map<String, Object> map) throws AppBusinessException;

	List<AdminRole> getAdminRole() throws AppBusinessException;

	int getAdminRoleCount(Map<String, Object> map) throws AppBusinessException;

	int getAdminResourceCount(Map<String, Object> map)
			throws AppBusinessException;

	List<AdminResource> getAdminResourceList(Map<String, Object> map)
			throws AppBusinessException;

	List<AdminRole> getAdminRoleList(Map<String, Object> map)
			throws AppBusinessException;

	/**
	 * 通过roleId查询资源.
	 * 
	 * @param id
	 * @return
	 * @throws AppBusinessException
	 */
	List<AdminResource> getAdminRoleResource(String id)
			throws AppBusinessException;

	List<AdminResource> getAdminResource() throws AppBusinessException;

	/**
	 * 根据角色id删除角色和资源的绑定关系.
	 * 
	 * @param roleId
	 * @throws AppBusinessException
	 */
	void deleteRoleResourceByRoleId(String roleId) throws AppBusinessException;

	/**
	 * 根据资源id删除角色和资源的绑定关系.
	 * 
	 * @param resourceId
	 * @throws AppBusinessException
	 */
	void deleteRoleResourceByResourceId(String resourceId)
			throws AppBusinessException;

	void insertUserResourceId(Map<String, Object> map)
			throws AppBusinessException;

	AdminUser getUserById(String id) throws AppBusinessException;

	AdminRole getRoleById(String id) throws AppBusinessException;

	AdminResource getResourceById(String id) throws AppBusinessException;
	
	/**
	 * author BruceZhang
	 * @param map
	 * @return	查询用户的资源
	 * @throws AppBusinessException
	 */
	List<AdminResource> getResourceByUser(Map<String, Object> map) throws AppBusinessException;
	
}
